class Apple{
	private String color;
	private double weight;
	public Apple(){}
	//提供有参数的构造器
	public Apple(String color,double weight){
		this.color = color;
		this.weight = weight;
	}
	//color.weight的setter和getter方法
	public void setColor(String color){
		this.color = color;
	}
	public String getColor(){
		return this.color;
	}
	public void setWeight(double weight){
		this.weight = weight;
	}
	public double getWeight(){
		return this.weight;
	}
	//重写toString()方法,用于实现Apple对象的"自我描述"
	// public String toString()
	// {
	// 	return "一个苹果,颜色是: " + color
	// 		+", 重量是: " + weight;
	// }
	// 这个是重写方法,当创建对象的时候.打印输出会直接调用toString方法
	// 如果不重写,则打印出Apple@659e0bfd 类名@对象内容
	public String toString(){
		return "Apple[color="+color+ ",weight="+weight+"]";
	}
}
public class ToStringTest{	
	public static void main(String[] args){
		Apple a = new Apple("红色",5.68);
		//打印Apple()对象
		System.out.println(a);
	}
}